<?php
session_start();
require_once( 'configs/config.php' );
require_once( 'lib/db.php' );
require_once( 'lib/functions.php' );
require_once(SMARTY_DIR . 'Smarty.class.php');
$smarty = new Smarty();

if( !isset( $_GET[ 'id' ] ) && isset( $_SESSION[ 'UID' ] ) )
{
	$id = $_SESSION[ 'UID' ];
	$smarty->assign('logged_in', 'true');
	$smarty->assign('self', 'true');
}
else if( (isset( $_SESSION[ 'UID' ] ) && $_GET[ 'id' ] == $_SESSION[ 'UID' ] ) )
{
	$smarty->assign('logged_in', 'true');
	$smarty->assign('self', 'true');
	$id = $_GET['id'];
}
else if( $_SESSION[ 'Level' ] == $config[ 'Admin' ] )
{
	$smarty->assign('logged_in', 'true');
	$smarty->assign('admin', 'true');
	$smarty->assign('self', 'true');
	$id = $_GET['id'];
}
else
{
	header( 'Location: login.php' );
	exit;
}



// Get list of tables from current database..
$dbUsers = $db->get_results('SELECT UserUID, FirstName, LastName, Email, PhoneNumber, Photograph, AIM, YIM, MSN, Address FROM users WHERE UserUID = ' . $id);

foreach($dbUsers[0] as $key => $value)
{
	$user[strtolower($key)] = $value;
}

$smarty->assign('title', 'Edit Account');
$smarty->assign('id', $id);
$smarty->assign('user', $user);
$smarty->assign('form', 'editAccountProcess.php');
$smarty->display('editAccount.tpl');

// get all assigned template vars
//$all_tpl_vars = $smarty->get_template_vars();
//print_r($all_tpl_vars);
?>
